/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.sms.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import com.chlitina.store.common.persistence.BaseDao;
import com.chlitina.store.common.persistence.BaseDaoImpl;
import com.chlitina.store.modules.sms.entity.SmsSendQueue;

/**
 * 短信DAO接口
 * @author lvbo
 * @version 2013-06-21
 */
public interface SmsSendQueueDao extends SmsSendQueueDaoCustom, CrudRepository<SmsSendQueue, Long> {
	
	@Query("from SmsSendQueue where PLAN_SEND_TIME BETWEEN ?1 AND ?2 AND status = 1")
	public List<SmsSendQueue> findByParameter(Date start, Date end);
	
	@Query("SELECT SUM(CEIL(CHAR_LENGTH(CONTENT)/?1)) from SmsSendQueue where PLAN_SEND_TIME BETWEEN ?2 AND ?3 AND status = 1")
	public Long countByParameter(long defaultLength, Date start, Date end);
}

/**
 * DAO自定义接口
 * @author lvbo
 */
interface SmsSendQueueDaoCustom extends BaseDao<SmsSendQueue> {

}

/**
 * DAO自定义接口实现
 * @author lvbo
 */
@Component
class SmsSendQueueDaoImpl extends BaseDaoImpl<SmsSendQueue> implements SmsSendQueueDaoCustom {

}
